package object02;

/**
 * @TODO
 * @Author xu
 * 2025/3/12
 */
public class StringBuilder03 {
    public static void main(String[] args) {
        String str1 = "abc";
        String str2 = "aba";
        String str3 = "abba";
        String str4 = "aaa";
        String str5 = "mnanm";

        System.out.println(str1 + " 是对称字符串: " + isPalindrome(str1));
        System.out.println(str2 + " 是对称字符串: " + isPalindrome(str2));
        System.out.println(str3 + " 是对称字符串: " + isPalindrome(str3));
        System.out.println(str4 + " 是对称字符串: " + isPalindrome(str4));
        System.out.println(str5 + " 是对称字符串: " + isPalindrome(str5));
    }

    // 判断字符串是否是对称字符串
    public static boolean isPalindrome(String str) {
        StringBuilder sb = new StringBuilder(str);
        return sb.toString().equals(sb.reverse().toString()); // 比较原始字符串和反转后的字符串
    }

}
